package com.cssw.fyzb.wap.controller;

import com.cssw.fyzb.base.web.context.UserContext;
import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.base.web.domain.AjaxPage;
import com.cssw.fyzb.wap.model.dto.AppealDto;
import com.cssw.fyzb.wap.model.vo.AddAppealVo;
import com.cssw.fyzb.wap.model.vo.AppealVo;
import com.cssw.fyzb.wap.service.AppealService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * @author
 */
@Api(description = "申述相关接口")
@RestController
@RequestMapping("/appeal")
public class AppealController {

    @Autowired
    private AppealService appealService;

    @ApiOperation(value = "用户的申述")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "页码, 从1开始", paramType = "query", dataType = "int", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页大小", paramType = "query", dataType = "int", required = true),
    })
    @RequestMapping(value = "/listAppeal", method = RequestMethod.GET)
    public AjaxPage<AppealVo> listAppeal(int pageNumber, int pageSize) {
        return appealService.listAppeal(UserContext.getUserId(), pageNumber, pageSize);
    }

    @ApiOperation(value = "用户的申述详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "appealId", value = "申述标识", paramType = "query", dataType = "String", required = true),
    })
    @RequestMapping(value = "/getAppeal", method = RequestMethod.GET)
    public AjaxData getAppeal(Long appealId) {
        return appealService.getAppeal(appealId);
    }

    @ApiOperation(value = "申述的类型")
    @RequestMapping(value = "/listAppealType", method = RequestMethod.GET)
    public AjaxData listAppealType() {
        return appealService.listAppealType();
    }

    @ApiOperation(value = "用户申述")
    @RequestMapping(value = "/saveAppeal", method = RequestMethod.POST)
    public AjaxData<AddAppealVo> saveAppeal(@RequestBody AppealDto dto, HttpServletRequest request, HttpServletResponse response) {
        return appealService.saveAppeal(UserContext.getUserId(), dto.getAppealType(), dto.getContact(), dto.getAppeal(), dto.getAppealAttach());
    }


}
